package com.iteye.cwh.system.service.impl;

import com.iteye.cwh.common.utils.DateUtils;
import com.iteye.cwh.system.domain.Employee;
import com.iteye.cwh.system.mapper.EmployeeMapper;
import com.iteye.cwh.system.service.IEmployeeService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 员工Service业务层处理
 * 
 * @author chenwh
 * @date 2024-02-17
 */
@Service
public class EmployeeServiceImpl implements IEmployeeService {
    @Autowired
    private EmployeeMapper employeeMapper;

    /**
     * 查询员工
     *
     * @param employeeId 员工主键
     * @return 员工
     */
    @Override
    public Employee selectEmployeeByEmployeeId(Long employeeId) {
        return employeeMapper.selectEmployeeByEmployeeId(employeeId);
    }

    /**
     * 查询员工列表
     *
     * @param employee 员工
     * @return 员工
     */
    @Override
    public List<Employee> selectEmployeeList(Employee employee) {
        return employeeMapper.selectEmployeeList(employee);
    }

    /**
     * 新增员工
     *
     * @param employee 员工
     * @return 结果
     */
    @Override
    public int insertEmployee(Employee employee) {
        employee.setCreateTime(DateUtils.getNowDate());
        return employeeMapper.insertEmployee(employee);
    }

    /**
     * 修改员工
     *
     * @param employee 员工
     * @return 结果
     */
    @Override
    public int updateEmployee(Employee employee) {
        employee.setUpdateTime(DateUtils.getNowDate());
        return employeeMapper.updateEmployee(employee);
    }

    /**
     * 批量删除员工
     *
     * @param employeeIds 需要删除的员工主键
     * @return 结果
     */
    @Override
    public int deleteEmployeeByEmployeeIds(Long[] employeeIds) {
        return employeeMapper.deleteEmployeeByEmployeeIds(employeeIds);
    }

    /**
     * 删除员工信息
     *
     * @param employeeId 员工主键
     * @return 结果
     */
    @Override
    public int deleteEmployeeByEmployeeId(Long employeeId) {
        return employeeMapper.deleteEmployeeByEmployeeId(employeeId);
    }

    /**
     * 查询仓管员
     * @return
     */
    @Override
    public List<Employee> selectWarehouseManegeList() {
        return employeeMapper.selectWarehouseManegeList();
    }


    /**
     * 根据岗位查询人员
     * @return
     */
    @Override
    public List<Employee> selectEmployeeByPostCode(String postCode) {
        return employeeMapper.selectEmployeeByPostCode(postCode);
    }
}
